<?php
include "../../../lib/list.php";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us">
<head>
<link rel="stylesheet" href="../../../css/list.css" type="text/css"></link>
<link rel="stylesheet" href="../../../css/table.blue.sorter.css" type="text/css" media="print, projection, screen"></link>
<link rel="stylesheet" href="../../../css/jquery.tablesorter.pager.css"	type="text/css" media="print, projection, screen"></link>
<script type="text/javascript" src="../../../js/jquery-1.2.6.js"></script>
<script type="text/javascript" src="../../../js/list.js"></script>
</head>
<body style="padding:0;margin:0;overflow-x: hidden;">
			<table cellspacing="1" class="tablesorter" style="padding:0;margin:0;">
				<tbody>
						<?php		
						if($mode=='search'){
							$s_no = $_POST['s_no'];
							$barcode = $_POST['barcode'];
							$name = $_POST['name'];
							$namegana = $_POST['namegana'];
							$bigcategory = $_POST['bigcategory'];
							$middlecategory = $_POST['middlecategory'];
							$smallcategory = $_POST['smallcategory'];
							$bumun = $_POST['bumun'];
							$buyer = $_POST['buyer'];
							
							if($s_no){
								$sear_char = " and uatp_stock.s_no = $s_no";
							}else{
								echo "<tr>
										<td style='text-align:center;height:154px;padding-top:20px'>
										<b>이동 될 점포부터 선택하셔야 합니다.</b>
										<br></br>
										<br></br><font color=#0078a5>** 상품은 총 100개 까지만 검색이 가능하며
										<br></br>상품마스터에서 재고관리를 선택하지 않은 제품은 
										<br></br>표시되지 않습니다.</font>
										</td>
								     </tr>";
								return false;
							}
							
							if($barcode){
								$sear_char .= " and barcode like '%$barcode%' ";
							}
							if($name){
								$sear_char .= " and productname like '%$name%' ";
							}
							if($namegana){
								$sear_char .= " and productnamegana like '%$namegana%' ";
							}
							if($bumun){
								$sear_char .= " and bumun_no = '$bumun' ";
							}
							if($buyer){
								$sear_char .= " and buyer = '$buyer' ";
							}
							if($bigcategory!='-1'&&$bigcategory){
								$sear_char .= " and b_no = $bigcategory ";
							}
							if($middlecategory!='-1'&&$middlecategory){
								$sear_char .= " and m_no = $middlecategory ";
							}
							if($smallcategory!='-1'&&$smallcategory){
								$sear_char .= " and s_no = $smallcategory ";
							}
						
						$query = "SELECT uatp_shopinfo.name AS 'shopname', uatp_product.no, uatp_product.barcode,
											uatp_product.productname, uatp_product.price1, 
											uatp_stock.count FROM uatp_stock INNER JOIN uatp_shopinfo ON uatp_stock.s_no = uatp_shopinfo.no 
											INNER JOIN uatp_product ON uatp_stock.p_no = uatp_product.no 
											WHERE 1 $sear_char order by no DESC LIMIT 0, 100";
						$result = DBquery($query);
						$total = DBnumrows($query);
						
						if($total==""){
							echo "<tr>	
										<td style='text-align:center;height:154px;padding-top:20px'>
										<b>검색조건에 맞는 상품이 존재하지 않습니다.</b>
										<br></br>
										<br></br><font color=#0078a5>** 상품은 총 100개 까지만 검색이 가능하며
										<br></br>상품마스터에서 재고관리를 선택하지 않은 제품은 
										<br></br>표시되지 않습니다.</font>
										</td>
								</tr>";
						}else{
						for($i=1; $list = mysql_fetch_array($result); $i++){							
							?>
							<tr>
								<td onclick="parent.product('<?=$list[no]?>','<?=$list[productname]?>','<?=$list[price1]?>','<?=$list[barcode]?>');FocusColor2(this);">
								<div style="height:25px;width:50px;float:right;font-size:15px;"><?=$list['count']?></div>
								<div style="width:200px;float:left;"><?=$list['barcode']?></div>
								<div style="width:200px;float:left;"><b><?=$list['productname']?></b></div>
								</td>
							</tr>
<?php
}
	mysql_free_result($result);
						}
						}else{
?>
				<tr>	
						<td style='text-align:center;height:154px;padding-top:20px'>
						검색 조건이 입력되지 않았습니다.
						<br></br>검색조건을 이용하여 상품을 검색해주세요.
						<br></br><font color=#0078a5>** 상품은 총 100개 까지만 검색이 가능하며
						<br></br>상품마스터에서 재고관리를 선택하지 않은 제품은 
						<br></br>표시되지 않습니다.</font>
						</td>
				</tr>
<?php }?>
			</tbody>
			</table>
</body>
</html>